import request from '@/config/axios'

export interface UserVO {
  id: number
  avatar: string | undefined
  birthday: number | undefined
  createTime: number | undefined
  loginDate: number | undefined
  loginIp: string
  mark: string
  phoneNumber: string
  name: string | undefined
  nickname: string | undefined
  registerIp: string
  sex: number
  status: number
  areaId: number | undefined
  areaName: string | undefined
  levelName: string | null
  point: number | undefined | null
  totalPoint: number | undefined | null
  experience: number | null | undefined
  idcard: string | undefined
  groupId: number | undefined
  deptId: number | undefined
  foreigner: number | undefined
  deptName: string | undefined
  birthPlace: string | undefined
  liveAddress: string | undefined
  lastLocation: string | undefined
  lastLocationTime: string | undefined
  groupName: string | undefined

  tagNames: string[] | undefined  // 会员标签列表
  country: string | undefined  // 国家
  nation: string | undefined  // 国籍/民族
  remark: string | undefined  // 备注（与mark区分开）
  carNumber: string | undefined  // 车牌号码
  passportNumber: string | undefined  // 护照号
  faith: string | undefined  // 宗教信仰
  paperNumber: string | undefined  // 证件号码（根据foreigner动态确定）
  frequentAddress: string | undefined  // 频繁出现地址
  appearanceCount: number | undefined // 频繁出现地址出现次数
}

// 定义人员类型接口
export interface Person {
  id: number
  name: string
  paperNumber: string
  foreigner: number
  isWarnSetting: boolean
  remark?: string
  tagNames?: string[]
}

// 查询人员列表
export const getUserPage = async (params) => {
  return await request.get({ url: `/member/user/page`, params })
}

// 查询事件设置人员列表
export const getCasePage = async (params) => {
  return await request.get({ url: `/member/user/casePage`, params })
}

// 查询预警设置人员列表
export const getWarnPage = async (params) => {
  return await request.get({ url: `/member/user/warnPage`, params })
}

// 查询预警设置人员列表
export const getPresentationPage = async (params) => {
  return await request.get({ url: `/member/user/presentationPage`, params })
}

// 通过证件号码查询人员
export const getPersonByIdCard = async (idcard: string) => {
  console.log('idcard====>', idcard)
  return await request.get({ url: `/member/user/getByIdCard`, params: { idcard } })
}

// 查询会员用户列表
export const getCaseUserPage = async (params) => {
  return await request.get({ url: `/member/user/pageCase`, params })
}

// 查询会员用户详情
export const getUser = async (id: number) => {
  return await request.get({ url: `/member/user/get?id=` + id })
}

// 新增重点人
export const createUser = async (data: UserVO) => {
  return await request.post({ url: `/member/user/create`, data })
}

// 修改会员用户
export const updateUser = async (data: UserVO) => {
  return await request.put({ url: `/member/user/update`, data })
}

// 修改会员用户
export const bindDeptMember = async (data: UserVO) => {
  return await request.put({ url: `/member/user/bindDeptMember`, data })
}

// 修改会员用户等级
export const updateUserLevel = async (data: any) => {
  return await request.put({ url: `/member/user/update-level`, data })
}

// 修改会员用户积分
export const updateUserPoint = async (data: any) => {
  return await request.put({ url: `/member/user/update-point`, data })
}
// 重置会员密码
export const restPw = async (data: any) => {
  return await request.put({ url: `/member/user/reset-password`, data })
}
// 重置会员密码
export const deleteUser = async (id: number) => {
  return await request.delete({ url: `/member/user/deleteUser?id=` + id })
}
// 下载用户导入模板
export const importPersonTemplate = () => {
  return request.download({ url: '/member/user/get-import-template' })
}
